﻿
@{
    ViewData["Title"] = "CustomerAddView";
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->

    <link href="~/libs/layui-v2.5.6/layui/css/layui.css" rel="stylesheet" />


</head>
<body>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">客户编码</label>
            <div class="layui-input-block">
                <input type="text" name="clientCode" lay-verify="required" placeholder="请输入" autocomplete="off" lay-reqtext="请填写客户编码" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">客户名称</label>
                <div class="layui-input-block">
                    <input type="text" name="clientName" lay-verify="required" placeholder="请输入" autocomplete="off" lay-reqtext="请填写客户名称" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客户简称</label>
            <div class="layui-input-block">
                <input type="text" name="clientNick" lay-verify="required" placeholder="请输入" autocomplete="off" lay-reqtext="请填写客户名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">客户类型</label>
                <div class="layui-input-block">
                    <input type="text" name="clientType" lay-verify="required" placeholder="请输入" autocomplete="off" lay-reqtext="请填写客户名称" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">客户电话</label>
            <div class="layui-input-block">
                <input type="text" name="tel" lay-verify="required" placeholder="请输入" autocomplete="off" lay-reqtext="请填写客户名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">联系人</label>
            <div class="layui-input-block">
                <input type="text" name="contact1" lay-verify="required" placeholder="请输入" autocomplete="off" lay-reqtext="请填写客户名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">联系人-电话</label>
            <div class="layui-input-block">
                <input type="text" name="contact1Tel" lay-verify="required" placeholder="请输入" autocomplete="off" lay-reqtext="请填写客户名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

    <script src="~/libs/layui-v2.5.6/layui/layui.js"></script>
    <script src="~/libs/jquery/jquery.js"></script>

    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    @* <script src="//unpkg.com/layui@2.9.17/dist/layui.js"></script> *@
    <script>

        layui.use(['form', 'jquery', 'layer'], function () {
            var form = layui.form;
            var $ = layui.jquery;
            var layer = layui.layer;

            // 监听提交
            form.on('submit(demo1)', function (data) {
                var field = data.field; // 获取表单字段值
                // console.log(field);
                // 显示填写结果，仅作演示用

                // 此处可执行 Ajax 等操作
                $.ajax({
                    url: "/SuJiaHao/GetCreateCustomer",
                    type: "get",
                    async: true,
                    data: field,
                    contentType: "application/json",
                    success: res => {
                        console.log(res.data);
                        if (res.data == 1) {
                            alert("添加成功")

                            var index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe 层的索引
                            parent.layer.close(index); // 再执行关闭
                            // location.href = "/Mdunitmeasure/Index";
                        }
                        else {
                            alert("添加失败")
                        }
                    }
                })



                // 阻止默认表单提交
                return false;
            });
        });
    </script>

</body>
</html>